package com.ningxun.rms.service.userservice.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningxun.rms.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ningxun.rms.mapper.basewechatuser.BaseWechatUserMapper;
import com.ningxun.rms.domain.basewechatuser.BaseWechatUser;
import com.ningxun.rms.service.userservice.IBaseWechatUserService;

/**
 * 微信用户信息Service业务层处理
 * 
 * @author rms
 * @date 2025-07-15
 */
@Service
public class BaseWechatUserServiceImpl extends ServiceImpl<BaseWechatUserMapper, BaseWechatUser> implements IBaseWechatUserService
{
    @Autowired
    private BaseWechatUserMapper baseWechatUserMapper;

    /**
     * 查询微信用户信息
     * 
     * @param userId 微信用户信息主键
     * @return 微信用户信息
     */
    @Override
    public BaseWechatUser selectBaseWechatUserByUserId(Long userId)
    {
        return baseWechatUserMapper.selectBaseWechatUserByUserId(userId);
    }

    /**
     * 查询微信用户信息列表
     * 
     * @param baseWechatUser 微信用户信息
     * @return 微信用户信息
     */
    @Override
    public List<BaseWechatUser> selectBaseWechatUserList(BaseWechatUser baseWechatUser)
    {
        return baseWechatUserMapper.selectBaseWechatUserList(baseWechatUser);
    }

    /**
     * 查询用户通过openid
     * @param openid 青年管理模块
     * @return
     */
    @Override
    public BaseWechatUser queryBaseWechatUserByopenid(String openid) {
        LambdaQueryWrapper<BaseWechatUser> wrapper = new LambdaQueryWrapper<BaseWechatUser>();
        wrapper.eq(BaseWechatUser::getOpenId , openid);
        return this.getOne(wrapper);
    }

    /**
     * 新增微信用户信息
     * 
     * @param baseWechatUser 微信用户信息
     * @return 结果
     */
    @Override
    public int insertBaseWechatUser(BaseWechatUser baseWechatUser)
    {
        baseWechatUser.setCreateTime(DateUtils.getNowDate());
        return baseWechatUserMapper.insertBaseWechatUser(baseWechatUser);
    }

    /**
     * 修改微信用户信息
     * 
     * @param baseWechatUser 微信用户信息
     * @return 结果
     */
    @Override
    public int updateBaseWechatUser(BaseWechatUser baseWechatUser)
    {
        baseWechatUser.setUpdateTime(DateUtils.getNowDate());
        return baseWechatUserMapper.updateBaseWechatUser(baseWechatUser);
    }

    /**
     * 批量删除微信用户信息
     * 
     * @param userIds 需要删除的微信用户信息主键
     * @return 结果
     */
    @Override
    public int deleteBaseWechatUserByUserIds(Long[] userIds)
    {
        return baseWechatUserMapper.deleteBaseWechatUserByUserIds(userIds);
    }

    /**
     * 删除微信用户信息信息
     * 
     * @param userId 微信用户信息主键
     * @return 结果
     */
    @Override
    public int deleteBaseWechatUserByUserId(Long userId)
    {
        return baseWechatUserMapper.deleteBaseWechatUserByUserId(userId);
    }
}
